package com.dimples.dd.system.model.vo;

import com.fasterxml.jackson.annotation.JsonInclude;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;

import java.util.List;

/**
 * 菜单路由视图对象
 *
 * @author zhongyj <1126834403@qq.com><br/>
 * @date 2024/6/30
 */
@Schema(description = "路由结果")
@Data
@JsonInclude(JsonInclude.Include.NON_NULL)
public class RouteVO {

    @Schema(description = "路由列表")
    private List<Routes> routes;

    @Schema(description = "路由列表")
    private String home;

    @Schema(description = "路由对象")
    @Data
    @JsonInclude(JsonInclude.Include.NON_NULL)
    public static class Routes {

        @Schema(description = "路由路径", example = "user")
        private String path;

        @Schema(description = "组件路径", example = "system/user/index")
        private String component;

        @Schema(description = "跳转链接", example = "https://www.youlai.tech")
        private String redirect;

        @Schema(description = "路由名称")
        private String name;

        @Schema(description = "路由属性")
        private Meta meta;

        @Schema(description = "路由属性")
        private Props props;

        @Schema(description = "子路由列表")
        private List<RouteVO.Routes> children;

        @Schema(description = "路由属性类型")
        @Data
        @JsonInclude(JsonInclude.Include.NON_NULL)
        public static class Meta {

            @Schema(description = "路由title")
            private String title;

            @Schema(description = "ICON")
            private String icon;

            @Schema(description = "是否隐藏(true-是 false-否)")
            private Boolean hideInMenu;

            @Schema(description = "i18nKey")
            private String i18nKey;

            @Schema(description = "拥有路由权限的角色编码")
            private List<String> roles;

            @Schema(description = "【菜单】是否开启页面缓存")
            @JsonInclude(JsonInclude.Include.NON_NULL)
            private Boolean keepAlive;

            @Schema(description = "【目录】只有一个子路由是否始终显示")
            @JsonInclude(JsonInclude.Include.NON_NULL)
            private Boolean alwaysShow;

            @Schema(description = "排序")
            private Integer sort;

            @Schema(description = "内部打开链接地址")
            private String href;

            @Schema(description = "进入该路由时激活的菜单键")
            private String activeMenu;

            @Schema(description = "默认情况下，相同路径的路由会共享一个标签页，若设置为true，则使用多个标签页")
            private Boolean multiTab;

            @Schema(description = "路由将在标签页中固定显示，其值表示固定标签页的顺序（首页是特殊的，它将自动保持fixed）")
            @JsonInclude(JsonInclude.Include.NON_NULL)
            private Integer fixedIndexInTab;
        }

        @Schema(description = "路由属性类型")
        @Data
        @JsonInclude(JsonInclude.Include.NON_NULL)
        public static class Props {
            @Schema(description = "新窗口打开链接地址")
            private String url;
        }

    }

    public static RouteVO.Routes.Meta createMeta() {
        return new RouteVO.Routes.Meta();
    }

    public static RouteVO.Routes.Props createProps() {
        return new RouteVO.Routes.Props();
    }
}
